<template>
	<web-view v-if="src !== ''" :src="src"></web-view>
</template>

<script>
	export default {
		onLoad(options) {
			if (options.isAccept) {
				//接收视频通话
				this.receiveInfo = options
			} else {
				//发起视频通话
				this.callInfo = options
			}
		},
		onShow() {
			if (this.receiveInfo.isAccept) {
				//接收视频通话
				this.src =
					`../../hybrid/html/call.html?sessionId=${this.receiveInfo.sessionId}&requestId=${this.receiveInfo.requestId}&requestAvatar=${this.receiveInfo.requestAvatar}&requestName=${this.receiveInfo.requestName}&receiveId=${this.receiveInfo.receiveId}&receiveAvatar=${this.receiveInfo.receiveAvatar}&receiveName=${this.receiveInfo.receiveName}&isAccept=true`;
			} else {
				//拨打视频通话
				this.src =
					`../../hybrid/html/call.html?sessionId=${this.callInfo.sessionId}&remoteId=${this.callInfo.remoteId}&remoteName=${this.callInfo.remoteName}&remoteAvatar=${this.callInfo.remoteAvatar}&loginId=${this.callInfo.loginId}&loginAvatar=${this.callInfo.loginAvatar}&loginName=${this.callInfo.loginName}&isAccept=false`;
			}
		},
		data() {
			return {
				isAccept: true, //是否是接听
				receiveInfo: {},
				callInfo: {},
				src: ''
			};
		},
		methods: {
			call() {
				uni.showToast({
					icon: "none",
					title: "打开摄像头"
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
